package com.itqf.yun.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itqf.yun.dto.ProductDto;
import com.itqf.yun.mapper.ProductMapper;
import com.itqf.yun.pojo.Product;
import com.itqf.yun.service.ProductService;
import com.itqf.yun.vo.R;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@MapperScan("com.itqf.yun.mapper")

public class ProductServiceImpl implements ProductService {


    @Autowired
    private ProductMapper productMapper;

    /**
     * 删除方法
     * @param
     * @return
     */
    @Override
    public R delete(int pid) {

        Product product = new Product();
        product.setPid(pid);
        product.setPdeleted(1);

        int row = productMapper.updateById(product);

        return R.OK("数据删除成功!");
    }



    /**
     * 展示
     * @return
     */
    @Override
    public R list() {

        QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("pdeleted",0);

        List<Product>   products = productMapper.selectList(queryWrapper);


        return R.OK("查询成功",products);
    }

}
